package de.luh.sim.ftn.graph;



/**
 * 
 * @author Dominik Molitor
 * @version 0.1
 * 
 */
public class Edge {
	private Node n1;
	private Node n2;
	private double cost;
	private int id;

	public Edge(Node n1, Node n2, int id) {
		this.n1 = n1;
		this.n2 = n2;
		this.id = id;
		cost = n1.distance(n2);
	}

	public Edge() {
	}

	public Edge copy() {
		Edge e = new Edge(new Node(n1.getX(), n1.getY(), n1.getId()), new Node(n2.getX(), n2.getY(), n2.getId()), id);
		return e;
	}

	@Override
	public boolean equals(Object e) {
		if ((((Edge) e).getN1().equals(n1) && ((Edge) e).getN2().equals(n2))
				|| (((Edge) e).getN1().equals(n2) && ((Edge) e).getN2().equals(n1))) {
			return true;
		}

		return false;
	}

	public Node getN1() {
		return n1;
	}

	public void setN1(Node n1) {
		this.n1 = n1;
	}

	public Node getN2() {
		return n2;
	}

	public void setN2(Node n2) {
		this.n2 = n2;
	}

	public double getCost() {
		return cost;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

}
